diff options
Diffstat (limited to 'src/share/classes/sun/font/FreetypeFontScaler.java')
-rw-r--r-- | src/share/classes/sun/font/FreetypeFontScaler.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/share/classes/sun/font/FreetypeFontScaler.java b/src/share/classes/sun/font/FreetypeFontScaler.java index dadca159fa..e55ba1fd7d 100644 --- a/src/share/classes/sun/font/FreetypeFontScaler.java +++ b/src/share/classes/sun/font/FreetypeFontScaler.java @@ -182,6 +182,9 @@ class FreetypeFontScaler extends FontScaler { return getLayoutTableCacheNative(nativeScaler); } + /* This method should not be called directly, in case + * it is being invoked from a thread with a native context. + */ public synchronized void dispose() { if (nativeScaler != 0L) { disposeNativeScaler(font.get(), nativeScaler); @@ -189,6 +192,21 @@ class FreetypeFontScaler extends FontScaler { } } + public synchronized void disposeScaler() { + if (nativeScaler != 0L) { + /* + * The current thread may be calling this method from the context + * of a JNI up-call. It will hold the native lock from the + * original down-call so can directly enter dispose and free + * the resources. So we need to schedule the disposal to happen + * only once we've returned from native. So by running the dispose + * on another thread which does nothing except that disposal we + * are sure that this is safe. + */ + new Thread(null, () -> dispose(), "free scaler", 0).start(); + } + } + synchronized int getNumGlyphs() throws FontScalerException { if (nativeScaler != 0L) { return getNumGlyphsNative(nativeScaler); @@ -225,7 +243,7 @@ class FreetypeFontScaler extends FontScaler { return getUnitsPerEMNative(nativeScaler); } - long createScalerContext(double[] matrix, + synchronized long createScalerContext(double[] matrix, int aa, int fm, float boldness, float italic, boolean disableHinting) { if (nativeScaler != 0L) { @@ -255,7 +273,7 @@ class FreetypeFontScaler extends FontScaler { private native GeneralPath getGlyphVectorOutlineNative(Font2D font, long pScalerContext, long pScaler, int[] glyphs, int numGlyphs, float x, float y); - native Point2D.Float getGlyphPointNative(Font2D font, + private native Point2D.Float getGlyphPointNative(Font2D font, long pScalerContext, long pScaler, int glyphCode, int ptNumber); private native long getLayoutTableCacheNative(long pScaler); @@ -268,7 +286,7 @@ class FreetypeFontScaler extends FontScaler { private native long getUnitsPerEMNative(long pScaler); - native long createScalerContextNative(long pScaler, double[] matrix, + private native long createScalerContextNative(long pScaler, double[] matrix, int aa, int fm, float boldness, float italic); /* Freetype scaler context does not contain any pointers that |